<?php

if (!isset($_COOKIE["checkLoginAdm"])) {
	
	header("Location: index.php");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/base.php.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="images/favicon.ico" type="image-x-icon"  />
<!-- InstanceBeginEditable name="doctitle" -->
<title>CineBD - A divers&atilde;o espera voc&ecirc;</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="cinebd.js"></script>
<style type="text/css">

	body {
		
		/*background-color:#80CFD8;*/
		background-color:#FFFFFF;
		/*background-image:url(../images/bg_thin.png);
		background-repeat:repeat-x;*/
		font-family:"Courier New", Courier, monospace;
		top:0px;
		margin-top:0px;
		padding:0px;
	} 
	
	a {
		
		text-decoration:none;
		color:#000;
	}
	
	.menu {
		
		color:#000000;
		text-align:center;
		font-size:18px;
		font-family:"Courier New", Courier, monospace;
		//border-bottom: 1px solid #03C ;
	}
	
	.menu:hover {
		
		border: 2px solid #FFF;
		//border-left: 5px solid #FFF;
		//border-bottom: 5px solid #FFF;
		//border-right: 10px solid #fff;
		//background-color: #06F;
	}
	
	.logo {
		width:150px;
		height:150px;
	}
	
	.header {
		background-image:url(images/Template_03.png);
		//background-repeat:repeat-x;
		width:300px;
		height:149px;
		text-align:center;
	}
	
	.sub_header {
		
		background-image:url(images/sub_header.png);
		width:681px;
		height:100px;
		text-align:center;
		font-size:18px;
		font-weight:bold;
		font-family:"Courier New", Courier, monospace;
		
	}
	
	.logout {
		
		font-size:14px;
		color:#FFF;
		
	}
	
	.logout:hover {
		
		border-bottom: 2px solid #FFF;
		
	}
	
	.left_menu {
		
		background-image:url(images/bg_thin.png);
		background-attachment:fixed;
		width:356px;
		height:768px;
		vertical-align:top;
		text-align:center;
	}
	
	.right_menu {
		
		background-image:url(images/bg_thin.png);
		background-attachment:fixed;
		width:355px;
		height:768px;
		vertical-align:top;
		font-size:15px;
		font-family:"Courier New", Courier, monospace;
		text-align:center;
	}
	
	.right_menu_text {
		
		text-align:center;
		font-size:16px;
	}
	
	.right_menu_text:hover {
		
		border-bottom: 2px solid #FFF;
	}
	
	.bottom_bg {
		background-image:url(images/bottom_bg.png);
		background-repeat:y;
	}
	
	.proximas {
		text-align:center;
		font-weight:bold;
		font-size:18px;
	}
	

	.content {
		
		text-align:center;
		vertical-align:text-top;
		font-size:12px;
		font-family:"Courier New", Courier, monospace;
		width:auto;
	}
	
	.linhaSessao {
		background-color:#FF9;
		font-weight:bold;
		text-align:center;
			
	}
	
	.colunaDias {
		background-color:#FF9;	
		font-weight:bold;
	}
	
	.centroTabela {
		background-color:#CC3333;
		color:#FFF;
		font-weight:bold;
	}
	
	.colunaIngressos {
		background-color:#FF9;	
		font-weight:bold;
	}
	
	.centroIngressos {
		font-weight:bold;
		text-align:center;
		
	}

	.ingressosBaratos {
		color:#090;
		font-weight:bold;
		text-align:center;
		
	}
	
	
	
	<!-- TemplateBeginEditable name="css" -->
	
	<!-- TemplateEndEditable -->
</style>
</head>

<body>
<table align="center" cellpadding="0" cellspacing="0" border="0" style="top:0px;margin-top:0px;">
	<tr>
    	<td rowspan="3" class="left_menu">
        	<a href="index.php">
            	<img class="logo" src="images/logo.png" />
            </a>
            <br /> 
            
            <table width="100%" cellpadding="0" cellspacing="8" align="center">
            	<tr>
                	<td>
                    	<span class="menu"><a href="emcartaz.php">&nbsp;EM CARTAZ&nbsp;</a></span>
                    </td>
                 </tr>
                 <tr>
                	<td>
                    	<span class="menu"><a href="quemsomos.php">&nbsp;QUEM SOMOS&nbsp;</a></span>
                    </td>
                 </tr>
                 <tr>
                	<td>
                    	<span class="menu"><a href="faleconosco.php">&nbsp;FALE CONOSCO&nbsp;</a></span>
                    </td>
                 </tr>
                 <tr>
                	<td>
                    	<span class="menu"><a href="ingressos.php">&nbsp;INGRESSOS&nbsp;</a></span>
                    </td>
                 </tr>
                 <tr>
                	<td>
                    	<span class="menu"><a href="#" id="clientes">&nbsp;CLIENTES&nbsp;</a></span>
                        <br />
                        <div id="menu_client" style="text-align:left; font-size:15px; display:none; margin-left:25%;">
                        	<ol style="list-style-type:none;">
                            	<li><a href="login.php">Logar</a></li>
                                <li><a href="cadastro.php">Cadastrar</a></li>                    
                            </ol>
                        </div>
                    </td>
                 </tr>
            </table> 
  		</td>
        <td class="header">
        	<img src="images/header.png" />
        </td>
                
        <td rowspan="3" class="right_menu">
          	<img class="logo" src="images/popcorn.png" style="margin-left:10px"/>
        	<table width="100%" cellpadding="0" cellspacing="8">
            	<tr>
                	<td class="proximas">
                    	PR&Oacute;XIMAS ESTREIAS
                    </td>
                    </tr>
                    <br />
                    <tr>
                    <td>
         
		<?php
				require_once("php/config.php");
				require_once("php/postgres.php");
				
				try {
					
					$confs = $GLOBALS["CONFIGS"]["PSQL_DB"];
					$pgcon = new PostgresConnection($confs["HOST"], $confs["PORT"], $confs["USER"], $confs["PASSWORD"], $confs["DATABASE"]);
            
					$estreias = $pgcon->getAllEstreias();					

                    echo" <table width='100%' cellpadding='0' cellspacing='8' align='center'>";
                        foreach ($estreias as $estreia) {
                    		$nome = $estreia["nome"];
                            echo "<tr>
                                <td>
                                    <span class='right_menu_text'><a href='#' onclick=\"javascript:opensinopse('$nome');\">&nbsp;" . $nome .  "&nbsp;</a></span>
                                </td>
                            </tr>";
             			}
        			echo "</table>					
            </td>
            </tr>          
            </table>
        </td>
    </tr>";    
   
            if (isset($_COOKIE["checkLogin"])){
            
             	echo" <tr> <td class='sub_header'>Ol&aacute;, $_COOKIE[checkLogin]!
                <span class='logout'><a href='logout.php'>Sair</a></span></td></tr>";
                
            } else {
            
            	echo' <td class="sub_header"></td>';
            }
        
 		} catch (PostgresConnectionException $pce) {
            
        echo "<span style='color:red;'>Desculpa, mas sua requisi&ccedil;&atilde;o n&atilde;o pode ser processada agora. Volte mais tarde.</span>";
        }
                    
?>
        
    
    <tr>
    	<td class="content">
        	<!-- InstanceBeginEditable name="content" -->
            <?php
			
				require_once("php/config.php");
				require_once("php/postgres.php");
				
				try {
		 
					$confs = $GLOBALS["CONFIGS"]["PSQL_DB"];
					$pgcon = new PostgresConnection($confs["HOST"], $confs["PORT"], $confs["USER"], $confs["PASSWORD"], $confs["DATABASE"]);
					if (isset($_GET["del"]) && $_GET["del"] == 1) {
				
						$datao = new DateTime(str_replace("/", "-", $_GET["data"]));
						$datastr = $datao->format("Y-m-d");
						$horastr = $datao->format("H:i");
						if ($pgcon->delExibicao($_GET["nome"], $datastr, $horastr, $_GET["sala"])) {
						
							echo "<span>Exibicao excluida com sucesso</span><br />";
						} else {
							
							echo "<span>Erro na exclusao da exibicao</span><br />";
						}
					}
					$exibicao = $pgcon->getAllExibitions2();
					for ($i = 1; $i <= count($exibicao); $i++) {
					
						foreach ($exibicao[$i] as $ex) {
						
							$ex["nome"] = trim($ex["nome"]);
							echo "<span>Sala: $i Filme: $ex[nome] Data: $ex[data_ex]</span>&nbsp;
									<a href='listExibicao.php?del=1&nome=$ex[nome]&sala=$i&data=$ex[data_ex]'>Excluir</a><br /><br />";
						}
					}
				} catch (PostgresConnectionException $pce) {
					
					echo "<span style='color:red;'>Desculpa, mas sua requisi&ccedil;&atilde;o n&atilde;o pode ser processada agora. Volte mais tarde.</span>";
				}
					
			?>
			<!-- InstanceEndEditable -->
    </tr>    
</table>
</body>
<!-- InstanceEnd --></html>
